import java.util.Arrays;

/**
 * @author 付大大
 * @description
 * @create 2021-01-21 14:24
 */
public class Test {
    public static void main(String[] args) {
        int reverse = reverse(0);
        System.out.println(reverse);
    }

    public static int reverse(int x) {
        char[] chars = Integer.toString(x).toCharArray();

        if (x > 0) {
            for (int i = 0, j = chars.length - 1; i < j; i++, j--) {
                char temp = chars[i];
                chars[i] = chars[j];
                chars[j] = temp;
            }
        } else if (x < 0) {
            for (int i = 1, j = chars.length - 1; i < j; i++, j--) {
                char temp = chars[i];
                chars[i] = chars[j];
                chars[j] = temp;
            }
        }
        double v = Double.parseDouble(String.valueOf(chars).trim());
        if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) {
            return 0;
        } else {
            int parseInt = (int) v;
            return parseInt;
        }
    }

}
